package com.zust.data.web.rest;

import com.zust.data.domain.param.ColumnSaveParam;
import com.zust.data.dto.ResponseDto;
import com.zust.data.serivce.ColumnService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.inject.Inject;

/**
 * @author senselyan
 * @Description: $
 * @date 2018/5/11 15:05
 */
@RestController
@RequestMapping("/column")
public class ColumnResource {

    @Inject
    private ColumnService columnService;

    @RequestMapping("/save")
    public ResponseDto save(ColumnSaveParam columnSaveParam) {
        return columnService.save(columnSaveParam);
    }

    @RequestMapping("/update")
    public ResponseDto update(
            @RequestParam("value")String value,
            @RequestParam(value = "columnId", required = true)String columnId,
            @RequestParam(value = "field", required = true)String field) {
        return columnService.update(columnId, field, value);
    }

    @RequestMapping("/delete/{columnId}")
    public ResponseDto delete(@PathVariable String columnId) {
        columnService.deleted(columnId);
        return new ResponseDto(true, "操作成功");
    }


}
